﻿using System;
using System.Runtime.InteropServices;

namespace DoeCSLogin
{
    class InetCookie
    {
        /// <summary>
        /// 写Cookie
        /// </summary>
        /// <param name="lpszUrlName">Cookie的网址</param>
        /// <param name="lbszCookieName">Cookie的标识</param>
        /// <param name="lpszCookieData">Cookie内容</param>
        /// <returns>是否成功</returns>
        [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);
        /// <summary>
        /// 读取Cookie
        /// </summary>
        /// <param name="lpszUrlName">Cookie的网址</param>
        /// <param name="lbszCookieName">Cookie的标识</param>
        /// <param name="lpszCookieData">Cookie内容</param>
        /// <param name="lpdwSize">数据缓存大小</param>
        /// <returns>是否成</returns>
        [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern bool InternetGetCookie(string lpszUrlName, string lbszCookieName, System.Text.StringBuilder lpszCookieData, ref int lpdwSize);
        /// <summary>
        /// 检测错误函数
        /// </summary>
        /// <returns>错误编号</returns>
        [DllImport("kernel32.dll")]
        public static extern Int32 GetLastError();
    }
}
